float screenWidth;
float screenHeight;

float lightStrength;
float lightRadius;
float3 lightPosition;
float3 lightColor;

struct VertexToPixel
{
	float4 Position : POSITION;
	float2 TexCoord : TEXCOORD0;
};

struct PixelToFrame
{
	float4 Color : COLOR0;
};

VertexToPixel VertexToPixelShader(float4 inPos : POSITION0, float2 texCoord : TEXCOORD0)
{
	VertexToPixel output = (VertexToPixel)0;
	
	output.Position = inPos;
	output.TexCoord = texCoord;
	
	return output;
}

PixelToFrame PointLightShader(VertexToPixel PSIn) : COLOR0
{
	PixelToFrame output = (PixelToFrame)0;
	
	float3 normal = float3(0, 1, 0);
	normalize(normal);
	
	float depth = 0.5f;
	
	float3 pixelPosition;
	pixelPosition.x = screenWidth * PSIn.TexCoord.x;
	pixelPosition.y = screenHeight * PSIn.TexCoord.y;
	pixelPosition.z = depth;
	
	float3 shading;
	if(depth > 0)
	{
		float3 lightDirection = lightPosition - pixelPosition;
		float distance = 1 / length(lightDirection) * lightStrength;
		distance = 0.5f;
		
		float amount = max(dot(normal, normalize(distance)), 0);
		
		float coneAttenuation = saturate(1.0f - length(lightDirection) / lightRadius);
		
		shading = distance * amount * coneAttenuation * lightColor * lightStrength;
	}
	
	output.Color = float4(shading.r, shading.g, shading.b, 1.0f);
	
	return output;
}

technique PointLight
{
	Pass Pass0
	{
		VertexShader = compile vs_2_0 VertexToPixelShader();
		PixelShader = compile ps_2_0 PointLightShader();
	}
}	